
	<div class="control-group row">
	
		<div class="navbar navbar-inverse navbar-fixed-top bs-docs-nav">
		  <ul class="breadcrumb">
			<li><a href="#">角色管理</a> <span class="divider">></span></li>
			<li class="active">编辑角色</li>
		  </ul>
		</div>
			

<?php
	
	$attrbutes = array(
		'class' => 'form-horizontal',
		'id' => 'form_edit'
	);
	echo form_open('role/edit',$attrbutes);
?>
	 <div class="control-group">
		 <label for='name' class="control-label"><s>*</s>角色名</label>
		  <div class="controls">
			<input type="text"  name="name" value="<?php echo $role['name'];?>" data-rules="{required:true}"/>
		  </div>
	</div>
	
	<div class="control-group">
		<label for='name' class="control-label">角色描述</label>
		<div class="controls">
			<input type="text"  name="content" value="<?php echo $role['content'];?>"/>
		</div>
	</div>
	
	<div class="control-group">
		<label for='status' class="control-label">状态</label>
		<div class="controls">
			<?php
			$data = array(
				'name'        => 'status',
				'id'          => 'status',
				'value'       => '1',
				'checked'     => ($role['status']==1)?true:false,
				'style'       => 'margin:10px',
			);

			echo form_radio($data); 
			echo form_label('启用');
			
			$data = array(
			'name'        => 'status',
			'id'          => 'status',
			'value'       => '0',
			'checked'     => ($role['status']==0)?true:false,
			'style'       => 'margin:10px',
			);

			echo form_radio($data);
			echo form_label('不启用');
			?>
		</div>
	</div>

	 <div class="control-group">
		 <label for='name' class="control-label"><s>*</s>权限</label>
			<input type="hidden" name="action_list">
		<div id="t1" class="span8"></div>
	</div>
	
   
   
   	<div class="actions-bar  centered">
			<input type="hidden" name="action" value="update">
			<input type="hidden" name="id" value="<?php echo $role['id'];?>">
			<input type="submit" class='button button-primary' checked="checked" value="添加角色"/>
			<input type="reset" class='button' checked="checked" value="重置"/>
	</div>
	
<?php

	echo form_close();
?>

	</div>
	
<!-- script start-->  
    <script type="text/javascript">
        BUI.use('bui/tree',function (Tree) {
        
      //树节点数据，
      //text : 文本，
      //id : 节点的id,
      //leaf ：标示是否叶子节点，可以不提供，根据childern,是否为空判断
      //expanded ： 是否默认展开
      //checked : 节点是否默认选中
      var data = 
                	<?php
                		if($role['action_list']){
                			echo json_encode($role['action_list']);
                		}
                	?>;

      //由于这个树，不显示根节点，所以可以不指定根节点
      var tree = new Tree.TreeList({
        render : '#t1',
        nodes : data,
        checkType: 'all', //checkType:勾选模式，提供了4中，all,onlyLeaf,none,custom
        showLine : true //显示连接线
      });
	  
      tree.render();
 
      tree.on('checkedchange',function(ev){
        var checkedNodes = tree.getCheckedNodes();
        var str = '';
        BUI.each(checkedNodes,function(node){
          str += node.id + ',';
        });
		$(':input[name="action_list"]').val(str);
      });
	  
    });
//form 验证
var Form = BUI.Form;
new Form.Form({
	srcNode:'#form_add'
}).render();
</script>